﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BusinnessLogicLayer;
using DevExpress.XtraEditors;
using DataTransferObject;
using System.IO;

namespace PresentationLayer
{
    public partial class UserControl1 : UserControl
    {
        public bool iscomplete;

        public UserControl1()
        {
            InitializeComponent();
            // This line of code is generated by Data Source Configuration Wizard
            refereeTableAdapter1.Fill(sangldDataSet1.REFEREE);
            // This line of code is generated by Data Source Configuration Wizard
        }

        private void UserControl1_Load(object sender, EventArgs e)
        {
            BUSTeam t = new BUSTeam();
            DataTable dt = t.getAllData();
            string teamName = (dt.Rows[0].ItemArray[2]).ToString(); 
            
            byte[] logo = (byte[])(dt.Rows[0]["Logo"]); 
          
            MemoryStream memory = new MemoryStream(logo);
            AddTtem(Image.FromStream(memory), teamName);
        }

        public void AddTtem(Image i, string teamName)
        {

            TileItem newTile = new TileItem();
            //First Frame - Image only
            TileItemFrame logoDXFrame = new TileItemFrame();
            TileItemElement logoEl = new TileItemElement();
            logoEl.Image = i;                                                                       //dien logo doi bong
            logoEl.ImageScaleMode = TileItemImageScaleMode.Stretch;
            logoDXFrame.Elements.Add(logoEl);
            logoDXFrame.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;
            //Second Frame - Text only
            TileItemFrame mottoDXFrame = new TileItemFrame();
            TileItemElement mottoEl = new TileItemElement();
            mottoEl.Text = "<Size=+2><Color=Sienna><b>" + teamName + "</b></Color></Size>"; //dien ten doi bong
            mottoEl.TextAlignment = TileItemContentAlignment.MiddleCenter;
            mottoDXFrame.Elements.Add(mottoEl);
            mottoDXFrame.Elements[0].AnimateTransition = DevExpress.Utils.DefaultBoolean.True;
            //Global Tile Item Settings
            newTile.Frames.Add(logoDXFrame);
            newTile.Frames.Add(mottoDXFrame);
            newTile.Appearance.BackColor = System.Drawing.Color.WhiteSmoke;
            //newTile.Appearance.BackColor2 = System.Drawing.Color.SandyBrown;
            newTile.Appearance.GradientMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal;
            newTile.Appearance.BorderColor = System.Drawing.Color.Bisque;
            //newTile.AllowHtmlText = DevExpress.Utils.DefaultBoolean.True;
            newTile.FrameAnimationInterval = 2500;
            newTile.ItemSize = TileItemSize.Medium;
            newTile.StartAnimation();
        }
         
        private void simpleButton1_Click(object sender, EventArgs e)
        {

          
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            DTOCardType cartType = new DTOCardType();
            cartType.cardTypeID = "C0005";
            cartType.cardTypeName = "the xanh";

            BUSCardType busCardType = new BUSCardType();
            busCardType.insertData(cartType);

        }

        private void rEFEREEBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.rEFEREEBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.sangldDataSet);

        }

        private void rEFEREEBindingNavigatorSaveItem_Click_1(object sender, EventArgs e)
        {
            this.Validate();
            this.rEFEREEBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.sangldDataSet);

        }
    }
}
